#lang racket


(require "../math.rkt"
         "../point.rkt")

(require "domain.rkt"
         "parametric-surface.rkt")


(provide make-sinwave
         sinwave-ax
         sinwave-ay
         sinwave-az)


(define-struct (sinwave parametric-surface)
  (ax ay az)
  #:constructor-name new-sinwave)


(define (sinwave-object ax ay az)
  (λ (u v)
    (let ((x (* ax u))
          (y (* ay v)))
      (xyz
       x
       y
       (* az (sin (sqrt (+ (^2 x) (^2 y)))))))))

(define (sinwave-tangent ax ay az)
  (λ (u v)
    (error 'sinwave-tangent "Not implemented")))

(define (sinwave-normal ax ay az)
  (λ (u v)
    (error 'sinwave-normal "Not implemented")))

(define (make-sinwave transformation ax ay az)
  (new-sinwave
   (make-domain 'closed (- 2pi) 'closed 2pi)
   (make-domain 'closed (- 2pi) 'closed 2pi)
   (sinwave-object ax ay az)
   (surface-tangent-default (sinwave-object ax ay az))
   (surface-normal-default (sinwave-object ax ay az))
   transformation
   ax
   ay
   az))